package setting

import (
	"context"
	"github.com/cloudwego/hertz/pkg/common/hlog"
	"mall_admin_api/biz/model"
	"mall_admin_api/biz/model/admin"
	"mall_admin_api/biz/pack"
)

func CreateBiz(ctx context.Context, req *admin.CreateBIZRequest, administrator *model.Administrator) error {
	var data model.Biz
	data.Name = req.Name
	data.Key = req.Key
	data.CreatedBy = administrator.Nickname
	//if err := dal.CreateBIZ(ctx, &data); err != nil {
	//	hlog.CtxErrorf(ctx, "dal.CreateBIZ err: %v", err)
	//	return err
	//}
	return nil
}

func GetBIZList(ctx context.Context, req *admin.GetBIZListRequest, page, limit int) ([]*admin.BIZ, int64, error) {
	//list, total, err := dal.GetBIZList(ctx, nil, page, limit)
	var list []*model.Biz
	var total int64
	var err error
	if err != nil {
		hlog.CtxErrorf(ctx, "dal.GetBIZList err: %v", err)
		return nil, 0, err
	}
	return pack.GetBIZList(list), total, nil
}
